<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">敏感词管理</ui:define>
    <ui:define name="content">

        <h:form>

            <p:dialog id="createModal" header="添加敏感词" position="center" widgetVar="createKeywordModal"
                      modal="true" width="600px">
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="keywordCreate" value="关键字"/>
                    <p:inputText id="keywordCreate" value="#{icpWebSensitiveKeywordBean.$.keyword}" style="width:100%"/>
                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确认添加" actionListener="#{icpWebSensitiveKeywordBean.onCreate()}"
                                     process="createModal" update="@form" />
                </div>
            </p:dialog>

            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="批量模式"
                                         icon="fa fa-list-ul"
                                         actionListener="#{icpWebSensitiveKeywordBean.changeModeToBatch}"
                                         update="@form"
                                         process="@this"
                                         rendered="#{icpWebSensitiveKeywordBean.isNotBatch()}"/>

                        <p:commandButton value="常规模式" icon="fa fa-file"
                                         actionListener="#{icpWebSensitiveKeywordBean.changeModeToNormal}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{icpWebSensitiveKeywordBean.isBatch()}"/>

                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="sensitiveKeywordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         rendered="#{icpWebSensitiveKeywordBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="发布" icon="fa fa-eye"
                                         rendered="#{icpWebSensitiveKeywordBean.isBatch()}"
                                         actionListener="#{icpWebSensitiveKeywordBean.onBatchPublish()}"
                                         update="@form"/>
                        <p:commandButton value="取消发布" icon="fa fa-eye-slash"
                                         rendered="#{icpWebSensitiveKeywordBean.isBatch()}"
                                         actionListener="#{icpWebSensitiveKeywordBean.onBatchUnPublish()}"
                                         update="@form"/>
                        <p:commandButton value="删除" icon="fa fa-times"
                                         rendered="#{icpWebSensitiveKeywordBean.isBatch()}"
                                         actionListener="#{icpWebSensitiveKeywordBean.onBatchDelete()}"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{icpWebSensitiveKeywordBean.isNormal()}"
                                         actionListener="#{icpWebSensitiveKeywordBean.onReset}"
                                         process="@this" update="@form"/>
                        <p:commandButton value="新增" icon="fa fa-plus"
                                         rendered="#{icpWebSensitiveKeywordBean.isNormal()}"
                                         onclick="PF('createKeywordModal').show()"
                                         />
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="keyword" value="敏感词"/>
                                <p:inputText id="keyword" value="#{icpWebSensitiveKeywordBean.$.keyword}"/>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="sensitiveKeywordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="sensitiveKeyword"
                                         value="#{icpWebSensitiveKeywordBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{icpWebSensitiveKeywordBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" style="width:70px;" rendered="#{icpWebSensitiveKeywordBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-eye"
                                                   process="@this" update="@form">
                                        <p:menuitem value="点击上线" icon="fa fa-eye"
                                                    actionListener="#{icpWebSensitiveKeywordBean.onPublish(sensitiveKeyword.pk)}"
                                                    rendered="#{!sensitiveKeyword.isPublish()}"
                                                    process="@this" update="@form"/>
                                        <p:menuitem value="点击下线" icon="fa fa-eye"
                                                    actionListener="#{icpWebSensitiveKeywordBean.onUnPublish(sensitiveKeyword.pk)}"
                                                    rendered="#{sensitiveKeyword.isPublish()}"
                                                    process="@this" update="@form"/>
                                        <p:menuitem value="删除" icon="fa fa-times"
                                                    actionListener="#{icpWebSensitiveKeywordBean.onDelete(sensitiveKeyword.pk)}"
                                                    process="@this" update="@form"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{icpWebSensitiveKeywordBean.isBatch()}"/>
                                <p:column headerText="ID">
                                    <h:outputText value="#{sensitiveKeyword.pk}"/>
                                </p:column>
                                <p:column headerText="敏感词" style="text-align:center;">
                                    <h:outputText value="#{sensitiveKeyword.keyword}"/>
                                </p:column>
                                <p:column headerText="状态" style="text-align:center;">
                                    <h:outputText value="#{sensitiveKeyword.getStatusStr()}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
